<template>
	<div>
		<div>
			{{this.$store.state.nOrder}}
		</div>
		<el-button @click="$router.go(-1)">返回购物车</el-button>
		<el-button type="warning" @click="addOrder">结算</el-button>
	</div>
</template>

<script>
	import orderApi from "@/api/order.js"
	import loginApi from "@/api/login.js"
	export default{
		data(){
			return{
				
			}
		},
		methods:{
			async addOrder(){
				let {data:res} = await orderApi.addOrder({user_id: this.$store.state.user_id, products: this.$store.state.nOrder})
				if(res.code == "001"){
					this.$notify({
					    message: res.msg,
					    type: 'success'
					});
					loginApi.getShoppingCart({user_id: this.$store.state.user_id})
					.then(res=>{
						if(res.data.code === "001"){
							this.$store.commit("setCartData",res.data.shoppingCartData)
						}
					})
					this.$router.push("/order")
				}
			}
		}
	}
</script>

<style>
</style>
